/**
 * @author huangyong
 */
public class BubbleSort {
    public static void sort(int[] array) {
        for (int i = 0; i < array.length; i++) {
            for (int n = 0; n < array.length - 1 - i; n++) {
                if (array[n] > array[n + 1]) {
                    swap(array, n, n + 1);
                }
            }
        }
    }

    private static void swap(int[] array, int minIndex, int index) {
        int temp = array[index];
        array[index] = array[minIndex];
        array[minIndex] = temp;
    }

}
